#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<stdlib.h>
#include<sys/wait.h>
int main()
{
    /*int ret=fork();

    if(ret==0)//子进程
    {
        int count=5;
        while(count)
        {
            printf("I am child:pid:%d  ppid:%d\n",getpid(),getppid());
            sleep(1);
            count--;
        }

        exit(10);
       
    }

    if(ret>0)
    {
        int status=0;
        pid_t k=waitpid(-1,&status,0);
        //int count=5;
        //while(count)
        //{
        //   printf("I am father:pid:%d  ppid:%d\n",getpid(),getppid());
        //   sleep(1);
        //   count--;
        //}
        //exit(222);
        //while(1)
        //{
        //   printf("I am father:pid:%d  ppid:%d\n",getpid(),getppid());
        //   sleep(1);
        //}
        printf("waiting\n");

        if(WIFEXITED(status))
        {
            printf("wait child success\n");
            printf("child exit_code:%d  sig_code:%d  curedump_code:%d\n",WEXITSTATUS(status),status&0X7f,status&0X80);
        }
        else
        {
            printf("wait child failed\n");
            
            printf("child exit_code:%d  sig_code:%d  curedump_code:%d\n",WEXITSTATUS(status),status&0X7f,status&0X80);
        }
    }*/

    int count=10;
    while(count)
    {
        printf("hahahahahahah\n");
        count--;

        if(count==5)
        {
            execlp("ls","ls","-a","-l",NULL);
        }
    }
    

    return 0;
}
